Ext.define('Jason.view.protal.dashboard.Dashboard', {
    extend: 'Ext.container.Container',
    title: '工作台', xtype: 'myDashboard', itemId: 'dashboard',
    style: 'background:#f7f8fa !important;',
    autoScroll: true,
    requires: [
        'Ext.ux.layout.ResponsiveColumn',
        'Jason.view.protal.dashboard.DashboardController',
        'Jason.view.protal.dashboard.DashboardViewModel',
        'Wys.view.InfoView',
        'Wys.highCharts.CustomHighCharts',
        'Wys.widgets.UserInfoWidget'
    ],
    controller: 'dashboard',
    viewModel: {
        type: 'dashboard'
    },
    listeners: {
        render: 'onBeforeRender'
    },
    items: [{
    	xtype : 'userInfoWidget',
		config:{
			loginTime:Ext.isEmpty(cfg.sub.accountInfo.lastLoginTime)?'第一次登录系统':Ext.Date.format(new Date(cfg.sub.accountInfo.lastLoginTime),'Y-m-d H-i-s'),
			dept: (session.get('dept') || ''),
			userName: (session.get('realname') || ''),
			userLogo:'resources/images/user-profile/defaults.png'
		}
    },{ 
    	xtype : 'customHighCharts',
    	margin:'8 0 0 0',
        autoLoad:true,
        width:300,
        height:200,
        xField: 'name',
        yField: {"logsum":'PC登录',"logsumYd":'移动端登录'},
        chartsType:'line',
        chartsData:[{
        	"name":"202207018",
			"logsum":80,
			"logsumYd":60,
			"stackTotal":120
		},{
        	"name":"202207019",
			"logsum":100,
			"logsumYd":20,
			"stackTotal":120
		},{
        	"name":"20220720",
			"logsum":160,
			"logsumYd":80,
			"stackTotal":120
		}],
        seriesConfig:{
            dataLabels: {
                enabled: false,
                formatter:function(){return this.y||'';}
            }
        },
        listeners:{
            pointselect:function(high,e){
          		alert(1);  	
            }
        },
        chartsConfig:{
            title: {text: '登录情况'},
            legend: {
                enabled: true
            },
            tooltip: {
                enabled:true,
                formatter: function (toolp) {
                    var tooltip=['<b>' + this.key + '日</b>'],
                        inde=this.point.index;
                    Ext.Array.each(toolp.chart.series,function(serie){
                        tooltip.push(serie.name + ':<b> ' + (serie.yData[inde]||0)+ '</b>');
                    });
                    tooltip.push('合计: <b> ' + (this.point.stackTotal||0)+ '</b>');
                    return tooltip.join('<br/>');
                }
            }
        }
    },{
    	xtype : 'customHighCharts',
    	margin:'8 0 0 0',
        autoLoad:true,
        width:300,
        height:200,
        xField: 'name',
        yField: {"logsum":'PC登录',"logsumYd":'移动端登录'},
        chartsType:'bar',
        listeners:{
            pointselect:function(high,e){
          		alert(1);  	
            }
        },
        reqConfig:{
        	url : cfg.requestUrlByLocal + '/app/localData/chartsData.json',
        	rootProperty:'data'
        },
        seriesConfig:{
            dataLabels: {
                enabled: false,
                formatter:function(){return this.y||'';}
            }
        },
        chartsConfig:{
            title: {text: '登录情况-AJAX'},
            legend: {
                enabled: true
            },
            tooltip: {
                enabled:true,
                formatter: function (toolp) {
                    var tooltip=['<b>' + this.key + '日</b>'],
                        inde=this.point.index;
                    Ext.Array.each(toolp.chart.series,function(serie){
                        tooltip.push(serie.name + ':<b> ' + (serie.yData[inde]||0)+ '</b>');
                    });
                    tooltip.push('合计: <b> ' + (this.point.stackTotal||0)+ '</b>');
                    return tooltip.join('<br/>');
                }
            }
        }
    }]
});
